<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" >
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排班规则-新增</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/plugins/bootstraptable/bootstrap-table.min.css">
    <link rel="stylesheet" href="/plugins/bootstrapValidator/css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="/css/font-awesome.css">
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="exampleForm">
						 	<div class="form-group">
						    </div>
						    <input id="ruleId" name="ruleId"  type="hidden">
						    <div class="form-group">
								<label class="col-xs-3 control-label text-right" >规则类别：</label>
								<div class="col-xs-6">
									<input id="ruleType" name="ruleType" class="form-control" type="text">
								</div>
							</div>
						    
                            <div class="form-group">
								<label class="col-xs-3 control-label text-right" >规则编码：</label>
								<div class="col-xs-8">
									<input id="ruleCode" name="ruleCode" class="form-control" type="text">
								</div>
							</div>
                            <div class="form-group">
								<label class="col-xs-3 control-label text-right" >规则说明：</label>
								<div class="col-xs-8">
									<textarea id="ruleContent" name="ruleContent" class="form-control" type="text" />
								</div>
							</div>
                            <div class="form-group">
								<label class="col-xs-3 control-label text-right" >规则得分：</label>
								<div class="col-xs-8">
									<input id="ruleScore" name="ruleScore"  class="form-control" type="text" required="required" 
									onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
									onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
									>
								</div>
							</div>
                            <div class="form-group">
								<label class="col-xs-3 control-label text-right">部门：</label>
								<div class="col-xs-8">
									<input id="dutyCode" name="dutyCode" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<div class="text-center">
									<button id="btn_save" onclick="save()" type="button" class="btn btn-primary">提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
	</div>

   
    <script src="/js/jquery.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="/plugins/bootstraptable/bootstrap-table.min.js"></script>
    <script src="/plugins/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/plugins/bootstrapValidator/js/bootstrapValidator.min.js"></script>
    <script src="/plugins/bootstrapValidator/js/language/zh_CN.js"></script>
    <script src="/plugins/layer/layer.js"></script>
	<!-- 自定义js -->
	<script type="text/javascript">
        var prefix = "/assignmentRule";
        $(function(){
            initValidator();
        });


        //保存
        function save(){
            $("#exampleForm").data('bootstrapValidator').validate();//触发一次所有的验证
            if(!$("#exampleForm").data('bootstrapValidator').isValid()){//判断验证是否已经通过
                return;
            }

            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/save",
                data : $('#exampleForm').serialize(),
                async : false,
                error : function(request) {
                    parent.layer.alert("Connection error");
                },
                success : function(data) {
                    if (data.code == 0) {
                        parent.layer.msg("操作成功");
                        parent.reload();
                        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                        parent.layer.close(index);
                    } else {
                        parent.layer.alert(data.msg)
                    }
                }
            });
        }

        //初始化验证规则
        function initValidator(){
           $('#exampleForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                username: {
                    message: 'The value is not valid',
                    validators: {
                        notEmpty: {
                            message: '此项不能为空'
                        }
                    }
                }
            }
        });
        }
	</script>
</body>
</html>
